home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1986 April / Ahoy_Magazine_86-04_1986_Double_L.d64 / printing perm (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  271b  |  12 lines

  1. 1 rem
  2. 2 rem problem #24-1 :
  3. 3 rem  printing permutations
  4. 4 rem solution by
  5. 5 rem  allan flippin
  6. 6 rem.
  7. 100 clr:input n:dimc(n-1):for i=1 to n:s$=s$+chr$(48+i):next
  8. 110 i=n-1:print s$,
  9. 120 s$=left$(s$,i-1)+right$(s$,n-i)+mid$(s$,i,1)
  10. 130 c(i)=c(i)+1:if c(i)<=n-i goto 110
  11. 140 c(i)=0:if i>1 then i=i-1 : goto 120
  12.